#ifndef __PRODUCERTHREAD_H_
#define __PRODUCERTHREAD_H_

#include "TaskQueue.hpp"
#include "Thread.hpp"
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>

namespace pc{

class ProducerThread
:public Thread{
public:
    ProducerThread(TaskQueue & q)
    :_taskQue(q)
    {

    }

private:
    void run() override{
        int cnt = 20;
        while(cnt-- > 0){
            srand(time(NULL));
            int num = rand() % 100;
            _taskQue.push(num);

            printf("produce num : %d\n",num);
            sleep(1);
        }
    }

private:
    TaskQueue & _taskQue;
};


}//end of namespace pc


#endif

